package com.only4play.practice.common.model;

import java.util.List;

public class PageResult<T> {
    private Long total;
    private Integer totalPages;
    private Integer pageSize;
    private Integer pageNumber;
    private List<T> list;

    public PageResult() {
    }

    public PageResult(List<T> list, Long total, Integer pageSize, Integer pageNumber) {
        this.list = list;
        this.total = total;
        this.pageSize = pageSize;
        this.pageNumber = pageNumber;
    }

    public static <T> PageResult of(List<T> list, Long total, Integer pageSize, Integer pageNumber) {
        return new PageResult(list, total, pageSize, pageNumber);
    }

    public Long getTotal() {
        return this.total;
    }

    public Integer getTotalPages() {
        return this.totalPages;
    }

    public Integer getPageSize() {
        return this.pageSize;
    }

    public Integer getPageNumber() {
        return this.pageNumber;
    }

    public List<T> getList() {
        return this.list;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public void setTotalPages(Integer totalPages) {
        this.totalPages = totalPages;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public void setPageNumber(Integer pageNumber) {
        this.pageNumber = pageNumber;
    }

    public void setList(List<T> list) {
        this.list = list;
    }



    @Override
    public String toString() {
        return "PageResult(total=" + this.getTotal() + ", totalPages=" + this.getTotalPages() + ", pageSize=" + this.getPageSize() + ", pageNumber=" + this.getPageNumber() + ", list=" + this.getList() + ")";
    }
}
